package org.pro.core.validateCode.image;

import java.io.IOException;

import javax.imageio.ImageIO;

import org.pro.core.validateCode.processor.AbstractValidateCodeProcessor;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.ServletWebRequest;


/**
 * 生成图片写回到客户端
 * @author luoqiz
 *
 */
@Component("imageValidateCodeProcessor")
public class ImageValidateCodeProcessor extends AbstractValidateCodeProcessor<ImageCode> {

	/**
	 * 发送图片验证码
	 */
	@Override
	protected void send(ServletWebRequest servletWebRequest, ImageCode validateCode) throws IOException {
		ImageIO.write(validateCode.getImage(), "jpg", servletWebRequest.getResponse().getOutputStream());
	}

}